<?php

namespace Ue\Providers;

use Illuminate\Support\ServiceProvider;

use Cache;

use Session;

use Ue\Cache\SaeStore;

use Illuminate\Cache\Repository;
use Illuminate\Session\CacheBasedSessionHandler;

class AppServiceProvider extends ServiceProvider {

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot() {
        
        Cache::extend('sae', function($app){
            return Cache::repository(new SaeStore());
        });
        
        Session::extend('sae', function($app){
            $minutes    = $app['config']['session.lifetime'];
            $cache      = new Repository(new SaeStore());
            return new CacheBasedSessionHandler($cache, $minutes);
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register() {

    }

}
